package com.leoman.dao;

import com.leoman.entity.Question;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by 涂奕恒 on 2014/12/4 16:16.
 */
public interface QuestionDao extends JpaRepository<Question, Integer>, JpaSpecificationExecutor<Question> {

    @Query("select a from Question a where a.isCut = 0")
    List<Question> findList();

    @Query("select a from Question a where a.isCut = 0 and a.type.name not like ?1")
    List<Question> findListNotByTypeName(String typeName);

    @Query("select a from Question a where a.isCut = 0 and a.type.name like ?1")
    List<Question> findListByTypeName(String typeName);

    @Query("select a from Question a where a.isCut = 0")
    Page<Question> findList(Pageable pageable);
}